

UPDATE FLW_ID_DATABASECHANGELOGLOCK SET LOCKED = 1, LOCKEDBY = '192.168.10.1 (192.168.10.1)', LOCKGRANTED = GETDATE() WHERE ID = 1 AND LOCKED = 0

UPDATE FLW_ID_DATABASECHANGELOGLOCK SET LOCKED = 0, LOCKEDBY = NULL, LOCKGRANTED = NULL WHERE ID = 1



UPDATE FLW_LIC_DATABASECHANGELOGLOCK SET LOCKED = 1, LOCKEDBY = '192.168.10.1 (192.168.10.1)', LOCKGRANTED = GETDATE() WHERE ID = 1 AND LOCKED = 0

UPDATE FLW_LIC_DATABASECHANGELOGLOCK SET LOCKED = 0, LOCKEDBY = NULL, LOCKGRANTED = NULL WHERE ID = 1



UPDATE FLW_PL_DATABASECHANGELOGLOCK SET LOCKED = 1, LOCKEDBY = '192.168.10.1 (192.168.10.1)', LOCKGRANTED = GETDATE() WHERE ID = 1 AND LOCKED = 0

UPDATE FLW_PL_DATABASECHANGELOGLOCK SET LOCKED = 0, LOCKEDBY = NULL, LOCKGRANTED = NULL WHERE ID = 1



UPDATE ACT_APP_DATABASECHANGELOGLOCK SET LOCKED = 1, LOCKEDBY = '192.168.10.1 (192.168.10.1)', LOCKGRANTED = GETDATE() WHERE ID = 1 AND LOCKED = 0

UPDATE ACT_APP_DATABASECHANGELOGLOCK SET LOCKED = 0, LOCKEDBY = NULL, LOCKGRANTED = NULL WHERE ID = 1



UPDATE FLW_FO_DATABASECHANGELOGLOCK SET LOCKED = 1, LOCKEDBY = '192.168.10.1 (192.168.10.1)', LOCKGRANTED = GETDATE() WHERE ID = 1 AND LOCKED = 0

UPDATE FLW_FO_DATABASECHANGELOGLOCK SET LOCKED = 0, LOCKEDBY = NULL, LOCKGRANTED = NULL WHERE ID = 1



UPDATE FLW_CO_DATABASECHANGELOGLOCK SET LOCKED = 1, LOCKEDBY = '192.168.10.1 (192.168.10.1)', LOCKGRANTED = GETDATE() WHERE ID = 1 AND LOCKED = 0

CREATE NONCLUSTERED INDEX idx_rendition_contentid ON FLW_CO_RENDITION_ITEM(CONTENT_ITEM_ID_)

CREATE NONCLUSTERED INDEX idx_metadata_contentid ON FLW_CO_METADATA(CONTENT_ITEM_ID_)

INSERT INTO FLW_CO_DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('14', 'flowable', 'com/flowable/content/db/liquibase/flowable-content-db-changelog.xml', GETDATE(), 14, '8:afbb9488d93f17414301a1ccef7ceb30', 'createIndex indexName=idx_rendition_contentid, tableName=FLW_CO_RENDITION_ITEM; createIndex indexName=idx_metadata_contentid, tableName=FLW_CO_METADATA', '', 'EXECUTED', NULL, NULL, '4.11.0', '8763133750')

UPDATE FLW_CO_DATABASECHANGELOGLOCK SET LOCKED = 0, LOCKEDBY = NULL, LOCKGRANTED = NULL WHERE ID = 1



UPDATE FLW_AD_DATABASECHANGELOGLOCK SET LOCKED = 1, LOCKEDBY = '192.168.10.1 (192.168.10.1)', LOCKGRANTED = GETDATE() WHERE ID = 1 AND LOCKED = 0

ALTER TABLE FLW_ACTION_INSTANCE ADD ICON_ nvarchar(255)

INSERT INTO FLW_AD_DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('17', 'flowable', 'com/flowable/action/db/liquibase/flowable-action-db-changelog.xml', GETDATE(), 17, '8:d2f74f4f85bd3f255700ab4c441fe6cb', 'addColumn tableName=FLW_ACTION_INSTANCE', '', 'EXECUTED', NULL, NULL, '4.11.0', '8763134400')

CREATE NONCLUSTERED INDEX ACT_IDX_SCOPE_ID_TYPE ON FLW_ACTION_INSTANCE(SCOPE_ID_, SCOPE_TYPE_)

CREATE NONCLUSTERED INDEX ACT_HI_IDX_SCOPE_ID_TYPE ON FLW_HI_ACTION_INSTANCE(SCOPE_ID_, SCOPE_TYPE_)

INSERT INTO FLW_AD_DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('18', 'flowable', 'com/flowable/action/db/liquibase/flowable-action-db-changelog.xml', GETDATE(), 18, '8:90f7eeb89565966bbd9517044d9e9a99', 'createIndex indexName=ACT_IDX_SCOPE_ID_TYPE, tableName=FLW_ACTION_INSTANCE; createIndex indexName=ACT_HI_IDX_SCOPE_ID_TYPE, tableName=FLW_HI_ACTION_INSTANCE', '', 'EXECUTED', NULL, NULL, '4.11.0', '8763134400')

UPDATE FLW_AD_DATABASECHANGELOGLOCK SET LOCKED = 0, LOCKEDBY = NULL, LOCKGRANTED = NULL WHERE ID = 1



UPDATE FLW_AU_DATABASECHANGELOGLOCK SET LOCKED = 1, LOCKEDBY = '192.168.10.1 (192.168.10.1)', LOCKGRANTED = GETDATE() WHERE ID = 1 AND LOCKED = 0

UPDATE FLW_AU_DATABASECHANGELOGLOCK SET LOCKED = 0, LOCKEDBY = NULL, LOCKGRANTED = NULL WHERE ID = 1



UPDATE FLW_DO_DATABASECHANGELOGLOCK SET LOCKED = 1, LOCKEDBY = '192.168.10.1 (192.168.10.1)', LOCKGRANTED = GETDATE() WHERE ID = 1 AND LOCKED = 0

UPDATE FLW_DO_DATABASECHANGELOGLOCK SET LOCKED = 0, LOCKEDBY = NULL, LOCKGRANTED = NULL WHERE ID = 1



UPDATE FLW_PO_DATABASECHANGELOGLOCK SET LOCKED = 1, LOCKEDBY = '192.168.10.1 (192.168.10.1)', LOCKGRANTED = GETDATE() WHERE ID = 1 AND LOCKED = 0

UPDATE FLW_PO_DATABASECHANGELOGLOCK SET LOCKED = 0, LOCKEDBY = NULL, LOCKGRANTED = NULL WHERE ID = 1



UPDATE FLW_SE_DATABASECHANGELOGLOCK SET LOCKED = 1, LOCKEDBY = '192.168.10.1 (192.168.10.1)', LOCKGRANTED = GETDATE() WHERE ID = 1 AND LOCKED = 0

UPDATE FLW_SE_DATABASECHANGELOGLOCK SET LOCKED = 0, LOCKEDBY = NULL, LOCKGRANTED = NULL WHERE ID = 1



UPDATE FLW_TP_DATABASECHANGELOGLOCK SET LOCKED = 1, LOCKEDBY = '192.168.10.1 (192.168.10.1)', LOCKGRANTED = GETDATE() WHERE ID = 1 AND LOCKED = 0

UPDATE FLW_TP_DATABASECHANGELOGLOCK SET LOCKED = 0, LOCKEDBY = NULL, LOCKGRANTED = NULL WHERE ID = 1



UPDATE FLW_ENG_DATABASECHANGELOGLOCK SET LOCKED = 1, LOCKEDBY = '192.168.10.1 (192.168.10.1)', LOCKGRANTED = GETDATE() WHERE ID = 1 AND LOCKED = 0

CREATE TABLE FLW_ENGAGE_CONV_USR_ACCOUNT (CONVERSATION_ID_ nvarchar(64) NOT NULL, USER_ACCOUNT_ID_ nvarchar(64) NOT NULL, CONSTRAINT FK_CONV_USER_ACCOUNT_ACCOUNT FOREIGN KEY (USER_ACCOUNT_ID_) REFERENCES FLW_ID_USER_ACCOUNT(ID_) ON DELETE CASCADE, CONSTRAINT FK_CONV_USER_ACCOUNT_CONV FOREIGN KEY (CONVERSATION_ID_) REFERENCES FLW_ENGAGE_CONVERSATION(ID_) ON DELETE CASCADE)

CREATE TABLE FLW_ENGAGE_MSG_REF_MAPPING (MESSAGE_ID_ nvarchar(64) NOT NULL, REFERENCE_ID_ nvarchar(64), REFERENCE_TYPE_ nvarchar(64), CONSTRAINT FK_MSG_REF_MAPPING_MESSAGE_ID FOREIGN KEY (MESSAGE_ID_) REFERENCES FLW_ENGAGE_MESSAGE(ID_) ON DELETE CASCADE)

INSERT INTO FLW_ENGAGE_MSG_REF_MAPPING(MESSAGE_ID_, REFERENCE_ID_, REFERENCE_TYPE_)
            SELECT
                MSG.ID_,
                MSG.REFERENCE_ID_,
                MSG.REFERENCE_TYPE_
            FROM FLW_ENGAGE_MESSAGE MSG
            WHERE MSG.REFERENCE_ID_ is not null

INSERT INTO FLW_ENGAGE_CONV_USR_ACCOUNT(CONVERSATION_ID_, USER_ACCOUNT_ID_)
            SELECT
                CONV.ID_,
                CONV.USER_ACCOUNT_ID_
            FROM FLW_ENGAGE_CONVERSATION CONV
            WHERE CONV.USER_ACCOUNT_ID_ is not null

CREATE NONCLUSTERED INDEX FLW_IDX_MSG_REF_MAPPING_REF ON FLW_ENGAGE_MSG_REF_MAPPING(REFERENCE_TYPE_, REFERENCE_ID_)

DROP INDEX FLW_IDX_MSG_REF_ID_REF_TYPE ON FLW_ENGAGE_MESSAGE

DECLARE @sql [nvarchar](MAX)
SELECT @sql = N'ALTER TABLE FLW_ENGAGE_MESSAGE DROP CONSTRAINT ' + QUOTENAME([df].[name]) FROM [sys].[columns] AS [c] INNER JOIN [sys].[default_constraints] AS [df] ON [df].[object_id] = [c].[default_object_id] WHERE [c].[object_id] = OBJECT_ID(N'FLW_ENGAGE_MESSAGE') AND [c].[name] = N'REFERENCE_ID_'
EXEC sp_executesql @sql

ALTER TABLE FLW_ENGAGE_MESSAGE DROP COLUMN REFERENCE_ID_

SELECT @sql = N'ALTER TABLE FLW_ENGAGE_MESSAGE DROP CONSTRAINT ' + QUOTENAME([df].[name]) FROM [sys].[columns] AS [c] INNER JOIN [sys].[default_constraints] AS [df] ON [df].[object_id] = [c].[default_object_id] WHERE [c].[object_id] = OBJECT_ID(N'FLW_ENGAGE_MESSAGE') AND [c].[name] = N'REFERENCE_TYPE_'
EXEC sp_executesql @sql

ALTER TABLE FLW_ENGAGE_MESSAGE DROP COLUMN REFERENCE_TYPE_

SELECT @sql = N'ALTER TABLE FLW_ENGAGE_TEMP_MESSAGE DROP CONSTRAINT ' + QUOTENAME([df].[name]) FROM [sys].[columns] AS [c] INNER JOIN [sys].[default_constraints] AS [df] ON [df].[object_id] = [c].[default_object_id] WHERE [c].[object_id] = OBJECT_ID(N'FLW_ENGAGE_TEMP_MESSAGE') AND [c].[name] = N'REFERENCE_ID_'
EXEC sp_executesql @sql

ALTER TABLE FLW_ENGAGE_TEMP_MESSAGE DROP COLUMN REFERENCE_ID_

SELECT @sql = N'ALTER TABLE FLW_ENGAGE_TEMP_MESSAGE DROP CONSTRAINT ' + QUOTENAME([df].[name]) FROM [sys].[columns] AS [c] INNER JOIN [sys].[default_constraints] AS [df] ON [df].[object_id] = [c].[default_object_id] WHERE [c].[object_id] = OBJECT_ID(N'FLW_ENGAGE_TEMP_MESSAGE') AND [c].[name] = N'REFERENCE_TYPE_'
EXEC sp_executesql @sql

ALTER TABLE FLW_ENGAGE_TEMP_MESSAGE DROP COLUMN REFERENCE_TYPE_

INSERT INTO FLW_ENG_DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('22', 'flowable', 'com/flowable/engage/db/liquibase/flowable-engage-db-changelog.xml', GETDATE(), 22, '8:cfd39cb39d39015f22d2981875e45955', 'createTable tableName=FLW_ENGAGE_CONV_USR_ACCOUNT; createTable tableName=FLW_ENGAGE_MSG_REF_MAPPING; sql; sql; createIndex indexName=FLW_IDX_MSG_REF_MAPPING_REF, tableName=FLW_ENGAGE_MSG_REF_MAPPING; dropIndex indexName=FLW_IDX_MSG_REF_ID_REF_TYPE...', '', 'EXECUTED', NULL, NULL, '4.11.0', '8763137944')

ALTER TABLE FLW_ENGAGE_CONVERSATION DROP CONSTRAINT FK_CONV_USER_ACCOUNT

DROP INDEX FLW_IDX_CONV_USER_ACCOUNT ON FLW_ENGAGE_CONVERSATION

SELECT @sql = N'ALTER TABLE FLW_ENGAGE_CONVERSATION DROP CONSTRAINT ' + QUOTENAME([df].[name]) FROM [sys].[columns] AS [c] INNER JOIN [sys].[default_constraints] AS [df] ON [df].[object_id] = [c].[default_object_id] WHERE [c].[object_id] = OBJECT_ID(N'FLW_ENGAGE_CONVERSATION') AND [c].[name] = N'USER_ACCOUNT_ID_'
EXEC sp_executesql @sql

ALTER TABLE FLW_ENGAGE_CONVERSATION DROP COLUMN USER_ACCOUNT_ID_

CREATE NONCLUSTERED INDEX FLW_IDX_CONV_USR_ACC_CONV ON FLW_ENGAGE_CONV_USR_ACCOUNT(CONVERSATION_ID_)

CREATE NONCLUSTERED INDEX FLW_IDX_CONV_USR_ACC_ACCOUNT ON FLW_ENGAGE_CONV_USR_ACCOUNT(USER_ACCOUNT_ID_)

CREATE NONCLUSTERED INDEX FLW_IDX_MSG_REF_MAPPING_MSG ON FLW_ENGAGE_MSG_REF_MAPPING(MESSAGE_ID_)

INSERT INTO FLW_ENG_DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('23', 'flowable', 'com/flowable/engage/db/liquibase/flowable-engage-db-changelog.xml', GETDATE(), 23, '8:c65cba0109fbcb2866e15079136ee361', 'dropForeignKeyConstraint baseTableName=FLW_ENGAGE_CONVERSATION, constraintName=FK_CONV_USER_ACCOUNT; dropIndex indexName=FLW_IDX_CONV_USER_ACCOUNT, tableName=FLW_ENGAGE_CONVERSATION; dropColumn columnName=USER_ACCOUNT_ID_, tableName=FLW_ENGAGE_CON...', '', 'EXECUTED', NULL, NULL, '4.11.0', '8763137944')

UPDATE FLW_ENG_DATABASECHANGELOGLOCK SET LOCKED = 0, LOCKEDBY = NULL, LOCKGRANTED = NULL WHERE ID = 1

